package com.bytedance.frameworks.baselib.network.http.c.a.a;

import com.bytedance.retrofit2.mime.MimeUtil;
import com.bytedance.retrofit2.mime.TypedInput;
import com.bytedance.retrofit2.Converter;
import com.google.gson.TypeAdapter;

import java.io.IOException;
import java.io.InputStreamReader;

final class c implements Converter {
    private final TypeAdapter a;

    c(TypeAdapter arg1) {
        this.a = arg1;
    }

    private Object a(TypedInput arg4) throws IOException {
        Object v0_3;
        String v0 = "UTF-8";
        if (arg4.mimeType() != null) {
            v0 = MimeUtil.parseCharset(arg4.mimeType(), v0);
        }
        InputStreamReader v1 = new InputStreamReader(arg4.in(), v0);
        com.google.gson.stream.JsonReader jsonReader = new com.google.gson.Gson().newJsonReader(v1);
        try {
            v0_3 = this.a.read(jsonReader);
        } catch (Throwable v0_2) {
            try {
                v1.close();
            } catch (IOException v1_1) {
            }

            throw v0_2;
        }

        try {
            v1.close();
        } catch (IOException v1_1) {
        }

        return v0_3;
    }

    public final Object convert(Object value) throws IOException {
        return this.a(((TypedInput) value));
    }
}

